import request from './request'
import {passwordHash} from '../utilities/crypto'
import {app} from '../utilities/app'
export function query ({currentPage = 1, perPage = 10, institutionNo, institutionName} = {}) {
  return request({
    url: '/console/institution/queryAllInfo.do',
    method: 'POST',
    body: {currentPage, perPage, institutionNo, institutionName}
  })
}

export function queryMechanism (id) {
  return request({
    url: '/console/institution/queryInfo.do',
    method: 'POST',
    body: {id}
  })
}

export function create ({institutionNo, institutionName, institutionDetails, institutionAddress, institutionPhone, industry, settledTime, status, institutionLogoPic, institutionColour,isIntegral, integralExchange}) {
  return request({
    url: '/console/institution/addInfo.do',
    method: 'POST',
    body: {institutionNo, institutionName, institutionDetails, institutionAddress, institutionPhone, industry, settledTime, status, institutionLogoPic, institutionColour,isIntegral, integralExchange}
  })
}

export function edit ({id, institutionNo, institutionName, institutionDetails, institutionAddress, institutionPhone, industry, settledTime, status, institutionLogoPic, institutionColour, isIntegral,integralExchange}) {
  return request({
    url: '/console/institution/updateInfo.do',
    method: 'POST',
    body: {institutionNo, institutionName, institutionDetails, institutionAddress, institutionPhone, industry, settledTime, status, institutionLogoPic, institutionColour,isIntegral, integralExchange}
  })
}

export function del (id) {
  return request({
    url: '/console/institution/deleteInfo.do',
    method: 'POST',
    body: {id}
  })
}

export function forbidden (id) {
  return request({
    url: '/console/institution/forbiddenInfo.do',
    method: 'POST',
    body: {id}
  })
}

export function use (id) {
  return request({
    url: '/console/institution/useInfo.do',
    method: 'POST',
    body: {id}
  })
}


export function reset (id, pwd) {
  pwd = passwordHash(pwd)
  return request({
    url: '/system/user/replaceUser.do',
    method: 'POST',
    body: {id, pwd}
  })
}
export function resett (oldP, newP) {
  oldP = passwordHash(oldP)
  newP = passwordHash(newP)
  return request({
    url: '/system/user/updatePwd.do',
    method: 'POST',
    body: {oldPwd: oldP, newPwd: newP}
  })
}

export function queryInsPro (institutionNo) {
  return request({
    url: '/console/institution/queryInstitutionProductInfo.do',
    method: 'POST',
    body: {institutionNo}
  })
}

export function updateInsPro ({institutionNo,productList}={}) {
  return request({
    url: '/console/institution/updateInstitutionProductInfo.do',
    method: 'POST',
    body: {institutionNo,productList}
  })
}

export function updateBanner ({institutionNo, id, name, seq, url, img}={}) {
  return request({
    url: '/console/institution/updateBanner.do',
    method: 'POST',
    body: {institutionNo, id, name, seq, url, img}
  })
}

export function addBanner ({institutionNo, name, seq, url, img}={}) {
  return request({
    url: '/console/institution/addBanner.do',
    method: 'POST',
    body: {institutionNo, name, seq, url, img}
  })
}

export function queryBanner (institutionNo) {
  return request({
    url: '/console/institution/queryBannerAll.do',
    method: 'POST',
    body: {institutionNo}
  })
}

export function queryBannerInfo ({institutionNo, id}={}) {
  return request({
    url: '/console/institution/queryBannerInfo.do',
    method: 'POST',
    body: {institutionNo, id}
  })
}

export function deleteBanner ({institutionNo, id}={}) {
  return request({
    url: '/console/institution/deleteBanner.do',
    method: 'POST',
    body: {institutionNo, id}
  })
}

export function cheackProduct({institutionNo, checkNo}={}) {
  return request({
    url: '/console/institution/checkInstitutionProductInfo.do',
    method: 'POST',
    body: {institutionNo, checkNo}
  })
}

export function cheackSucc({institutionNo, checkNo}={}) {
  return request({
    url: '/console/institution/checkSuccInstitutionProductInfo.do',
    method: 'POST',
    body: {institutionNo, checkNo}
  })
}

export function cheacknuSucc({institutionNo, checkNo}={}) {
  return request({
    url: '/console/institution/checkUnsuccInstitutionProductInfo.do',
    method: 'POST',
    body: {institutionNo, checkNo}
  })
}

export function queryProDetail({productNo, productName}={}) {
  return request({
    url: '/console/institution/queryProductDetail.do',
    method: 'POST',
    body: {productNo, productName}
  })
}